package illiax.training.convertidordetemperatura

import android.app.Activity
import android.os.Bundle
import android.widget.EditText
import android.view.View
import android.widget.Toast

class MainActivity extends Activity {
  var text: EditText = null

  override def onCreate(savedInstanceState: Bundle): Unit = {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    text = findViewById(R.id.editText1).asInstanceOf[EditText]
    () => {} 
    
  }

  def onClick(view: View): Unit = {
    /* view.getId() match {
      case R.id.button1 =>
        var celsiusButton = findViewById(R.id.radioButton1)
        var fahrenheitButton = findViewById(R.id.radioButton2)
        if (text.getText().length() == 0)
          Toast.makeText(this, "are you fucking kiding me?", Toast.LENGTH_LONG).show()
        return
        var inputValue = augmentString(text.getText().toString).toFloat
    }*/
    text.setText(((s : String) => s)("sasa"))
  }

}

    
/*
  public void onClick(View view) {
    switch (view.getId()) {
    case R.id.button1:
      RadioButton celsiusButton = (RadioButton) findViewById(R.id.radio0);
      RadioButton fahrenheitButton = (RadioButton) findViewById(R.id.radio1);
      if (text.getText().length() == 0) {
        Toast.makeText(this, "Please enter a valid number",
            Toast.LENGTH_LONG).show();
        return;
      }

      float inputValue = Float.parseFloat(text.getText().toString());
      if (celsiusButton.isChecked()) {
        text.setText(String
            .valueOf(convertFahrenheitToCelsius(inputValue)));
        celsiusButton.setChecked(false);
        fahrenheitButton.setChecked(true);
      } else {
        text.setText(String
            .valueOf(convertCelsiusToFahrenheit(inputValue)));
        fahrenheitButton.setChecked(false);
        celsiusButton.setChecked(true);
      }
      break;
    }
  }

  // Converts to celsius
  private float convertFahrenheitToCelsius(float fahrenheit) {
    return ((fahrenheit - 32) * 5 / 9);
  }

  // Converts to fahrenheit
  private float convertCelsiusToFahrenheit(float celsius) {
    return ((celsius * 9) / 5) + 32;
  }
} 

*/